package com.hzeport.bgs22emduty.inbound.api;

import com.hzeport.bgs22emduty.dto.dutyTel.DutyTelDTO;
import com.hzeport.bgs22emduty.dto.dutyTel.DutyTelVO;
import com.hzeport.bgs22emduty.dto.dutyTel.IdDTO;
import com.hzeport.bgs22emduty.dto.dutyTel.ParamDutyVO;
import com.hzeport.bgs22emduty.service.DutyTelService;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/dutyTel")
@RequiredArgsConstructor
@Api(tags = "值班电话设置相关接口")
public class DutyTelController {

    private final DutyTelService dutyTelService;

    @GetMapping("/list")
    @ApiOperation(value = "值班电话列表")
    public BaseResult<List<DutyTelVO>> list() {
        return BaseResult.ok(dutyTelService.list(), "获取成功");
    }

    @PostMapping("/create")
    @ApiOperation(value = "值班电话添加")
    public BaseResult<Void> create(@Valid @RequestBody DutyTelDTO dutyTelDTO) {
        dutyTelService.create(dutyTelDTO);
        return BaseResult.ok(null, "添加成功");
    }

    @PostMapping("/delete")
    @ApiOperation(value = "值班电话删除")
    public BaseResult<Void> delete(@Valid @RequestBody IdDTO idDTO) {
        dutyTelService.delete(idDTO);
        return BaseResult.ok(null, "删除成功");
    }

    @GetMapping("/paramDutyList")
    @ApiOperation(value = "值班时段列表")
    public BaseResult<List<ParamDutyVO>> sType() {
        return BaseResult.ok(dutyTelService.paramDutyList(), "获取成功");
    }
}
